package com.gxa.modules.service.impl;

import com.gxa.common.vo.JsonResult;
import com.gxa.common.vo.PageRecv;
import com.gxa.common.vo.ResultVo;
import com.gxa.modules.mapper.Loanafter_Interestrate_ChangeMapper;
import com.gxa.modules.pojo.LoanSearch;
import com.gxa.modules.pojo.Loanafter_Interestrate_Change;
import com.gxa.modules.service.Loanafter_Interestrate_ChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/28 11:17
 * Description:
 * Version: V1.0
 */
@Service
public class Loanafter_Interestrate_ChangeServiceImpl implements Loanafter_Interestrate_ChangeService{
    @Autowired(required = false)
    private Loanafter_Interestrate_ChangeMapper loanafter_interestrate_changeMapper;
    @Override
    public ResultVo addChange(Loanafter_Interestrate_Change loanafter_interestrate_change) {
        loanafter_interestrate_changeMapper.addChange(loanafter_interestrate_change);
        ResultVo r =new ResultVo();
        r.setData(loanafter_interestrate_change.getChange_id());
        r.setCode(200);
        r.setMsg("添加成功！");
        return r;
    }

    @Override
    public JsonResult queryChange(PageRecv<LoanSearch> pageRecv) {
        //对查询页面参数计算
        Integer currentPage=pageRecv.getCurrentPage();
        Integer pageSize=pageRecv.getPageSize();
        Integer limit1=(currentPage-1)*pageSize;
        pageRecv.setCurrentPage(limit1);

        //调用Mapper方法获取返回结果
        List<Loanafter_Interestrate_Change> list=loanafter_interestrate_changeMapper.queryChange(pageRecv);
        Integer count=loanafter_interestrate_changeMapper.queryChangeCount(pageRecv.getData());

        //将结果塞入R
        JsonResult r=new JsonResult();
        r.setData(list);
        r.setCode(200);
        r.setMsg("查询成功！");
        r.setCount(count);
        return r;
    }
}
